from typing import *


class Solution:

    def maximumSwap(self, num: int) -> int:
        s = list(str(num))
        for i in range(len(s)):
            sw = -1
            for j in range(len(s) - 1, i, -1):
                if s[j] > s[i] and (sw == -1 or s[j] > s[sw]):
                    sw = j
            if sw > 0:
                s[i], s[sw] = s[sw], s[i]
                return int("".join(s))
        return num


print(list(123))